package com.broker.starter.service;

import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

public interface MinIOService {

    /**
     * 文件上传
     * @param file
     * @param bucketName
     * @param contentType
     * @return
     */
    Optional<String> upload(MultipartFile file, String bucketName , String contentType) throws IOException;
    /**
     * 对象上传
     * @param bucketName
     * @param objectName
     * @param contentType
     * @param stream
     * @param objectSize
     * @param partSize
     * @return
     */
    Optional<String> upload(String bucketName, String objectName, String contentType, InputStream stream, long objectSize, long partSize);



    /**
     * 对象下载
     * @param bucketName
     * @param objectName
     * @param fileName
     */
    void download(String bucketName, String objectName, String fileName);

    /**
     * 对象删除
     * @param bucketName
     * @param objectName
     */
    void delete(String bucketName, String objectName);

    /**
     * 获取对象存储URL
     * @param bucketName
     * @param objectName
     * @return
     */
    Optional<String> getObjUrl(String bucketName, String objectName);

    /**
     * 获取对象存储URL
     * @param bucketName
     * @param objectName
     * @param duration
     * @param unit
     * @return
     */
    Optional<String> getObjUrl(String bucketName, String objectName, int duration, TimeUnit unit);

}
